Module c3d.cal3d
ModuleInfo "Version: 0.1"
ModuleInfo "Main Author: Cal3d."
ModuleInfo "License: You are free to use this code as you please"
ModuleInfo "Please see readme.txt for more details"

Import BRL.Math

Include "includes/math.bmx"
Include "includes/data.bmx"
Include "includes/bounding.bmx"
Include "includes/stringmap.bmx"
Include "includes/intmap.bmx"
Include "includes/corematerial.bmx"
Include "includes/coresubmesh.bmx"
Include "includes/coremesh.bmx"
Include "includes/corebone.bmx"
Include "includes/coreskeleton.bmx"
Include "includes/coremodel.bmx"
Include "includes/coreanimation.bmx"
Include "includes/corekeyframe.bmx"
Include "includes/coretrack.bmx"
Include "includes/coremorphtrack.bmx"
Include "includes/coremorphkeyframe.bmx"
Include "includes/coremorphanimation.bmx"
Include "includes/coreanimatedmorph.bmx"
Include "includes/coresubmorphtarget.bmx"
Include "includes/submesh.bmx"
Include "includes/mesh.bmx"
Include "includes/bone.bmx"
Include "includes/skeleton.bmx"
Include "includes/model.bmx"
Include "includes/animation.bmx"
Include "includes/mixer.bmx"
Include "includes/morphtargetmixer.bmx"
Include "includes/physique.bmx"
Include "includes/springsystem.bmx"
Include "includes/renderer.bmx"


Global Delta:DeltaTimer = DeltaTimer.CreateDelta(30)


Type DeltaTimer
	
	Field targetfps:Int = 60
	Field currentticks:Int
	Field rtime:Int
	Field lastticks:Int
	Field frametime:Int
	Field delta:Float
	Field frames:Int
	Field actualFPS:Int
	
	Function CreateDelta:DeltaTimer(fps:Int)
		Local d:DeltaTimer = New DeltaTimer
		d.targetfps = fps
		d.lastticks = MilliSecs()
		Return d
	End Function
	
	
		
	Method UpdateDelta()
		currentticks = MilliSecs()
		frametime = currentticks - lastticks
		delta = Float(frametime) / Float(1000.0 / Float(targetfps))
		If delta = 0 Then delta = 0.01
		frames = frames + 1
		If MilliSecs()-rtime > 1000 Then
			actualFPS = frames
			frames = 0
			rtime = MilliSecs()
		EndIf
		lastticks = currentticks
	End Method
	
End Type